<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>快速体验luckysheet</title>
    <link rel='stylesheet' href='module/luckysheel-2.1.13/plugins/css/pluginsCss.css' />
    <link rel='stylesheet' href='module/luckysheel-2.1.13/plugins/plugins.css' />
    <link rel='stylesheet' href='module/luckysheel-2.1.13/css/luckysheet.css' />
    <link rel='stylesheet' href='module/luckysheel-2.1.13/assets/iconfont/iconfont.css' />
    <script src="module/luckysheel-2.1.13/plugins/js/plugin.js"></script>
    <script src="module/luckysheel-2.1.13/luckysheet.umd.js"></script>

</head>

<body>
    <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;">
    </div>
   <script>
       $(function () {
           var name = "";
           while(name.length == 0){
               name = prompt("请输入昵称")
           }

           var autoSave;
           //配置项
           var options = {
               lang: 'zh',
               container: 'luckysheet',
               allowUpdate: true,
               loadUrl:"http://"+ location.host +"/get",
               hook:{
                   updated:function(e){
                       //监听更新,并在3s后自动保存
                       if(autoSave) clearTimeout(autoSave)
                       $(luckysheet_info_detail_save).text("已修改")
                       autoSave = setTimeout(function(){
                           var excel = luckysheet.getAllSheets();
                           //去除临时数据,减小体积
                           for(var i in excel) excel[i].data = undefined
                           $.post(
                               "http://" + location.host + "/set",
                               {jsonExcel:JSON.stringify(excel)},
                               function(){
                                   $(luckysheet_info_detail_save).text("已保存")
                               })
                       },3 * 1000)
                       return true;
                   }
               },
               updateUrl: "ws://" + location.hostname +":11551/" + name
           }

           console.log(JSON.stringify(options))
           luckysheet.create(options)
       })

   </script>
</body>

</html>